package com.lly.config;

import com.lly.entry.TaskInfo;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import org.springframework.util.StringUtils;

import java.util.Iterator;

public class CustomerModel {

    private ObservableList<TaskInfo> taskTableData = FXCollections.observableArrayList();

    public ObservableList<TaskInfo> getTaskTableData() {
        return taskTableData;
    }


    public void addTaskInfo(TaskInfo taskInfo){
        if (!taskTableData.contains(taskInfo)){
            taskTableData.add(taskInfo);
        }
    }

    public void removeTaskInfo(String taskName){
        if (StringUtils.isEmpty(taskName)){
            return;
        }
        Iterator<TaskInfo> taskInfoIterator = taskTableData.iterator();
        while (taskInfoIterator.hasNext()){
            TaskInfo taskTableDatum = taskInfoIterator.next();
            if (taskTableDatum.getTaskName().equals(taskName)){
                taskInfoIterator.remove();
            }
        }

    }

    public void showTask(){

    }

}
